package com.txunda.zhuohired.aty.manage.my;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.widget.TextView;

import com.lidroid.xutils.view.annotation.ViewInject;
import com.txunda.zhuohired.R;
import com.txunda.zhuohired.base.BaseAty;
import com.txunda.zhuohired.fgt.user.home.CompanyFgt;
import com.txunda.zhuohired.fgt.user.home.CompanyOneFgt;
import com.txunda.zhuohired.fgt.user.home.CompanyTwoFgt;

import java.util.ArrayList;
import java.util.List;

/**
 * 创建人： Txd_Cjh
 * 创建时间： 2018/3/14 14:24
 * 功能描述：公司详情
 * 联系方式：jiahuanchen@126.com
 */

public class ManageDisplayAty extends BaseAty {
    /**
     * 标题
     */
    @ViewInject(R.id.tv_layout_white_center)
    private TextView tv_layout_white_center;

    @ViewInject(R.id.tl_manage_display)
    private TabLayout tl_manage_display;

    @ViewInject(R.id.vp_manage_display)
    private ViewPager vp_manage_display;
    private ArrayList<Fragment> mFragments;
    private MyPagerAdapter myPagerAdapter;

    private List<String> tittleList;
    private String[] tittleStr = {"公司介绍", "全部职位", "兼职职位"};
    private String u_id = "";

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        showStatusBar(R.id.layout_white_head);
        tv_layout_white_center.setText("公司详情");
    }

    @Override
    protected int getLayoutResId() {
        return R.layout.aty_manage_display;
    }

    @Override
    protected void initialized() {
        u_id = getIntent().getStringExtra("u_id");
        tittleList = new ArrayList();
        mFragments = new ArrayList<>();
        myPagerAdapter = new MyPagerAdapter(getSupportFragmentManager());
        for (int i = 0; i < tittleStr.length; i++) {
            tittleList.add(tittleStr[i]);
        }
        mFragments.add(CompanyFgt.getFgt(0, u_id));
        mFragments.add(CompanyOneFgt.getFgt(1, u_id));
        mFragments.add(CompanyTwoFgt.getFgt(2, u_id));
        //        for (int y = 0; y < tittleList.size(); y++) {
        //
        //        }
    }

    @Override
    protected void requestData() {
        vp_manage_display.setAdapter(myPagerAdapter);
        tl_manage_display.setupWithViewPager(vp_manage_display);
    }

    private class MyPagerAdapter extends FragmentPagerAdapter {
        public MyPagerAdapter(FragmentManager fm) {
            super(fm);
        }


        @Override
        public int getCount() {
            return mFragments.size();
        }

        @Override
        public CharSequence getPageTitle(int position) {
            return tittleList.get(position);
        }

        @Override
        public Fragment getItem(int position) {
            return mFragments.get(position);
        }
    }
}
